﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using DocViewer.DBUtility;//Please add references
namespace DY.DAL
{
    /// <summary>
    /// 数据访问类:View_UserWithProtocol
    /// </summary>
    public partial class View_UserWithProtocol
    {
        public View_UserWithProtocol()
        { }
        #region  Method

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from View_UserWithProtocol");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters = {
					new SqlParameter("@id", SqlDbType.Int,4)			};
            parameters[0].Value = id;

            return DbHelperSQL.Exists(strSql.ToString(), parameters);
        }


        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(DY.Model.View_UserWithProtocol model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into View_UserWithProtocol(");
            strSql.Append("CardId,Name,VillageName,Population,Mobile,Photo,id,ProtocolId,ProtocolType,OwnerId,Chai_Time,Chai_Structure,Chai_MainCovers,Chai_MainArea,Chai_AttachedCovers,Chai_AttachedArea,Chai_Fangqianwuhou,Chai_ReclamationLotNo,An_Time,An_Type,An_Address,An_HouseNo,An_Covers,An_Area,An_BuildType,Fei_ShiGongBaoZhengJin,Fei_WeiYueFaKuan,Fei_DaiJianShuiNiYingHua,Fei_ChaiJiaJiangLi,Fei_AnZhiYanQiBuChang,Fei_ShiGongShuiDianFei,Fei_ShuiBiaoKaiHuFei,Fei_DianBiaoAnZhuangFei,Fei_LaJiQingYunFei,Fei_DiJiBuChaFei,Fei_ZhengCeXingBuZhu,Fei_GuoDuQiFangZu,Fei_ChaiJiuFei,Fei_ShiJiaoFeiYong,Fei_YiJiaoShuE,Fei_WeiJiaoShuE,Remark,ProtocolPhoto,Fei_YingJiaoShuE,An_ChaiJianNo,An_ChaiJianArea,An_GeLou,Fei_FangKuanShuE,Fei_GeLouJinE,Fei_ChaiJianJinE,An_HuXing,An_TaoShu)");
            strSql.Append(" values (");
            strSql.Append("@CardId,@Name,@VillageName,@Population,@Mobile,@Photo,@id,@ProtocolId,@ProtocolType,@OwnerId,@Chai_Time,@Chai_Structure,@Chai_MainCovers,@Chai_MainArea,@Chai_AttachedCovers,@Chai_AttachedArea,@Chai_Fangqianwuhou,@Chai_ReclamationLotNo,@An_Time,@An_Type,@An_Address,@An_HouseNo,@An_Covers,@An_Area,@An_BuildType,@Fei_ShiGongBaoZhengJin,@Fei_WeiYueFaKuan,@Fei_DaiJianShuiNiYingHua,@Fei_ChaiJiaJiangLi,@Fei_AnZhiYanQiBuChang,@Fei_ShiGongShuiDianFei,@Fei_ShuiBiaoKaiHuFei,@Fei_DianBiaoAnZhuangFei,@Fei_LaJiQingYunFei,@Fei_DiJiBuChaFei,@Fei_ZhengCeXingBuZhu,@Fei_GuoDuQiFangZu,@Fei_ChaiJiuFei,@Fei_ShiJiaoFeiYong,@Fei_YiJiaoShuE,@Fei_WeiJiaoShuE,@Remark,@ProtocolPhoto,@Fei_YingJiaoShuE,@An_ChaiJianNo,@An_ChaiJianArea,@An_GeLou,@Fei_FangKuanShuE,@Fei_GeLouJinE,@Fei_ChaiJianJinE,@An_HuXing,@An_TaoShu)");
            SqlParameter[] parameters = {
					new SqlParameter("@CardId", SqlDbType.VarChar,50),
					new SqlParameter("@Name", SqlDbType.VarChar,50),
					new SqlParameter("@VillageName", SqlDbType.VarChar,150),
					new SqlParameter("@Population", SqlDbType.Int,4),
					new SqlParameter("@Mobile", SqlDbType.VarChar,50),
					new SqlParameter("@Photo", SqlDbType.VarChar,80),
					new SqlParameter("@id", SqlDbType.Int,4),
					new SqlParameter("@ProtocolId", SqlDbType.VarChar,150),
					new SqlParameter("@ProtocolType", SqlDbType.VarChar,50),
					new SqlParameter("@OwnerId", SqlDbType.Int,4),
					new SqlParameter("@Chai_Time", SqlDbType.Date,3),
					new SqlParameter("@Chai_Structure", SqlDbType.VarChar,50),
					new SqlParameter("@Chai_MainCovers", SqlDbType.Float,8),
					new SqlParameter("@Chai_MainArea", SqlDbType.Float,8),
					new SqlParameter("@Chai_AttachedCovers", SqlDbType.Float,8),
					new SqlParameter("@Chai_AttachedArea", SqlDbType.Float,8),
					new SqlParameter("@Chai_Fangqianwuhou", SqlDbType.Float,8),
					new SqlParameter("@Chai_ReclamationLotNo", SqlDbType.VarChar,50),
					new SqlParameter("@An_Time", SqlDbType.Date,3),
					new SqlParameter("@An_Type", SqlDbType.VarChar,50),
					new SqlParameter("@An_Address", SqlDbType.VarChar,50),
					new SqlParameter("@An_HouseNo", SqlDbType.VarChar,50),
					new SqlParameter("@An_Covers", SqlDbType.Float,8),
					new SqlParameter("@An_Area", SqlDbType.Float,8),
					new SqlParameter("@An_BuildType", SqlDbType.VarChar,50),
					new SqlParameter("@Fei_ShiGongBaoZhengJin", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_WeiYueFaKuan", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_DaiJianShuiNiYingHua", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_ChaiJiaJiangLi", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_AnZhiYanQiBuChang", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_ShiGongShuiDianFei", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_ShuiBiaoKaiHuFei", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_DianBiaoAnZhuangFei", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_LaJiQingYunFei", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_DiJiBuChaFei", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_ZhengCeXingBuZhu", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_GuoDuQiFangZu", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_ChaiJiuFei", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_ShiJiaoFeiYong", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_YiJiaoShuE", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_WeiJiaoShuE", SqlDbType.Decimal,9),
					new SqlParameter("@Remark", SqlDbType.VarChar,500),
					new SqlParameter("@ProtocolPhoto", SqlDbType.VarChar,80),
					new SqlParameter("@Fei_YingJiaoShuE", SqlDbType.Decimal,9),
					new SqlParameter("@An_ChaiJianNo", SqlDbType.VarChar,50),
					new SqlParameter("@An_ChaiJianArea", SqlDbType.Float,8),
					new SqlParameter("@An_GeLou", SqlDbType.Int,4),
					new SqlParameter("@Fei_FangKuanShuE", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_GeLouJinE", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_ChaiJianJinE", SqlDbType.Decimal,9),
					new SqlParameter("@An_HuXing", SqlDbType.VarChar,50),
					new SqlParameter("@An_TaoShu", SqlDbType.Int,4)};
            parameters[0].Value = model.CardId;
            parameters[1].Value = model.Name;
            parameters[2].Value = model.VillageName;
            parameters[3].Value = model.Population;
            parameters[4].Value = model.Mobile;
            parameters[5].Value = model.Photo;
            parameters[6].Value = model.id;
            parameters[7].Value = model.ProtocolId;
            parameters[8].Value = model.ProtocolType;
            parameters[9].Value = model.OwnerId;
            parameters[10].Value = model.Chai_Time;
            parameters[11].Value = model.Chai_Structure;
            parameters[12].Value = model.Chai_MainCovers;
            parameters[13].Value = model.Chai_MainArea;
            parameters[14].Value = model.Chai_AttachedCovers;
            parameters[15].Value = model.Chai_AttachedArea;
            parameters[16].Value = model.Chai_Fangqianwuhou;
            parameters[17].Value = model.Chai_ReclamationLotNo;
            parameters[18].Value = model.An_Time;
            parameters[19].Value = model.An_Type;
            parameters[20].Value = model.An_Address;
            parameters[21].Value = model.An_HouseNo;
            parameters[22].Value = model.An_Covers;
            parameters[23].Value = model.An_Area;
            parameters[24].Value = model.An_BuildType;
            parameters[25].Value = model.Fei_ShiGongBaoZhengJin;
            parameters[26].Value = model.Fei_WeiYueFaKuan;
            parameters[27].Value = model.Fei_DaiJianShuiNiYingHua;
            parameters[28].Value = model.Fei_ChaiJiaJiangLi;
            parameters[29].Value = model.Fei_AnZhiYanQiBuChang;
            parameters[30].Value = model.Fei_ShiGongShuiDianFei;
            parameters[31].Value = model.Fei_ShuiBiaoKaiHuFei;
            parameters[32].Value = model.Fei_DianBiaoAnZhuangFei;
            parameters[33].Value = model.Fei_LaJiQingYunFei;
            parameters[34].Value = model.Fei_DiJiBuChaFei;
            parameters[35].Value = model.Fei_ZhengCeXingBuZhu;
            parameters[36].Value = model.Fei_GuoDuQiFangZu;
            parameters[37].Value = model.Fei_ChaiJiuFei;
            parameters[38].Value = model.Fei_ShiJiaoFeiYong;
            parameters[39].Value = model.Fei_YiJiaoShuE;
            parameters[40].Value = model.Fei_WeiJiaoShuE;
            parameters[41].Value = model.Remark;
            parameters[42].Value = model.ProtocolPhoto;
            parameters[43].Value = model.Fei_YingJiaoShuE;
            parameters[44].Value = model.An_ChaiJianNo;
            parameters[45].Value = model.An_ChaiJianArea;
            parameters[46].Value = model.An_GeLou;
            parameters[47].Value = model.Fei_FangKuanShuE;
            parameters[48].Value = model.Fei_GeLouJinE;
            parameters[49].Value = model.Fei_ChaiJianJinE;
            parameters[50].Value = model.An_HuXing;
            parameters[51].Value = model.An_TaoShu;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(DY.Model.View_UserWithProtocol model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update View_UserWithProtocol set ");
            strSql.Append("CardId=@CardId,");
            strSql.Append("Name=@Name,");
            strSql.Append("VillageName=@VillageName,");
            strSql.Append("Population=@Population,");
            strSql.Append("Mobile=@Mobile,");
            strSql.Append("Photo=@Photo,");
            strSql.Append("id=@id,");
            strSql.Append("ProtocolId=@ProtocolId,");
            strSql.Append("ProtocolType=@ProtocolType,");
            strSql.Append("OwnerId=@OwnerId,");
            strSql.Append("Chai_Time=@Chai_Time,");
            strSql.Append("Chai_Structure=@Chai_Structure,");
            strSql.Append("Chai_MainCovers=@Chai_MainCovers,");
            strSql.Append("Chai_MainArea=@Chai_MainArea,");
            strSql.Append("Chai_AttachedCovers=@Chai_AttachedCovers,");
            strSql.Append("Chai_AttachedArea=@Chai_AttachedArea,");
            strSql.Append("Chai_Fangqianwuhou=@Chai_Fangqianwuhou,");
            strSql.Append("Chai_ReclamationLotNo=@Chai_ReclamationLotNo,");
            strSql.Append("An_Time=@An_Time,");
            strSql.Append("An_Type=@An_Type,");
            strSql.Append("An_Address=@An_Address,");
            strSql.Append("An_HouseNo=@An_HouseNo,");
            strSql.Append("An_Covers=@An_Covers,");
            strSql.Append("An_Area=@An_Area,");
            strSql.Append("An_BuildType=@An_BuildType,");
            strSql.Append("Fei_ShiGongBaoZhengJin=@Fei_ShiGongBaoZhengJin,");
            strSql.Append("Fei_WeiYueFaKuan=@Fei_WeiYueFaKuan,");
            strSql.Append("Fei_DaiJianShuiNiYingHua=@Fei_DaiJianShuiNiYingHua,");
            strSql.Append("Fei_ChaiJiaJiangLi=@Fei_ChaiJiaJiangLi,");
            strSql.Append("Fei_AnZhiYanQiBuChang=@Fei_AnZhiYanQiBuChang,");
            strSql.Append("Fei_ShiGongShuiDianFei=@Fei_ShiGongShuiDianFei,");
            strSql.Append("Fei_ShuiBiaoKaiHuFei=@Fei_ShuiBiaoKaiHuFei,");
            strSql.Append("Fei_DianBiaoAnZhuangFei=@Fei_DianBiaoAnZhuangFei,");
            strSql.Append("Fei_LaJiQingYunFei=@Fei_LaJiQingYunFei,");
            strSql.Append("Fei_DiJiBuChaFei=@Fei_DiJiBuChaFei,");
            strSql.Append("Fei_ZhengCeXingBuZhu=@Fei_ZhengCeXingBuZhu,");
            strSql.Append("Fei_GuoDuQiFangZu=@Fei_GuoDuQiFangZu,");
            strSql.Append("Fei_ChaiJiuFei=@Fei_ChaiJiuFei,");
            strSql.Append("Fei_ShiJiaoFeiYong=@Fei_ShiJiaoFeiYong,");
            strSql.Append("Fei_YiJiaoShuE=@Fei_YiJiaoShuE,");
            strSql.Append("Fei_WeiJiaoShuE=@Fei_WeiJiaoShuE,");
            strSql.Append("Remark=@Remark,");
            strSql.Append("ProtocolPhoto=@ProtocolPhoto,");
            strSql.Append("Fei_YingJiaoShuE=@Fei_YingJiaoShuE,");
            strSql.Append("An_ChaiJianNo=@An_ChaiJianNo,");
            strSql.Append("An_ChaiJianArea=@An_ChaiJianArea,");
            strSql.Append("An_GeLou=@An_GeLou,");
            strSql.Append("Fei_FangKuanShuE=@Fei_FangKuanShuE,");
            strSql.Append("Fei_GeLouJinE=@Fei_GeLouJinE,");
            strSql.Append("Fei_ChaiJianJinE=@Fei_ChaiJianJinE,");
            strSql.Append("An_HuXing=@An_HuXing,");
            strSql.Append("An_TaoShu=@An_TaoShu");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters = {
					new SqlParameter("@CardId", SqlDbType.VarChar,50),
					new SqlParameter("@Name", SqlDbType.VarChar,50),
					new SqlParameter("@VillageName", SqlDbType.VarChar,150),
					new SqlParameter("@Population", SqlDbType.Int,4),
					new SqlParameter("@Mobile", SqlDbType.VarChar,50),
					new SqlParameter("@Photo", SqlDbType.VarChar,80),
					new SqlParameter("@id", SqlDbType.Int,4),
					new SqlParameter("@ProtocolId", SqlDbType.VarChar,150),
					new SqlParameter("@ProtocolType", SqlDbType.VarChar,50),
					new SqlParameter("@OwnerId", SqlDbType.Int,4),
					new SqlParameter("@Chai_Time", SqlDbType.Date,3),
					new SqlParameter("@Chai_Structure", SqlDbType.VarChar,50),
					new SqlParameter("@Chai_MainCovers", SqlDbType.Float,8),
					new SqlParameter("@Chai_MainArea", SqlDbType.Float,8),
					new SqlParameter("@Chai_AttachedCovers", SqlDbType.Float,8),
					new SqlParameter("@Chai_AttachedArea", SqlDbType.Float,8),
					new SqlParameter("@Chai_Fangqianwuhou", SqlDbType.Float,8),
					new SqlParameter("@Chai_ReclamationLotNo", SqlDbType.VarChar,50),
					new SqlParameter("@An_Time", SqlDbType.Date,3),
					new SqlParameter("@An_Type", SqlDbType.VarChar,50),
					new SqlParameter("@An_Address", SqlDbType.VarChar,50),
					new SqlParameter("@An_HouseNo", SqlDbType.VarChar,50),
					new SqlParameter("@An_Covers", SqlDbType.Float,8),
					new SqlParameter("@An_Area", SqlDbType.Float,8),
					new SqlParameter("@An_BuildType", SqlDbType.VarChar,50),
					new SqlParameter("@Fei_ShiGongBaoZhengJin", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_WeiYueFaKuan", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_DaiJianShuiNiYingHua", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_ChaiJiaJiangLi", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_AnZhiYanQiBuChang", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_ShiGongShuiDianFei", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_ShuiBiaoKaiHuFei", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_DianBiaoAnZhuangFei", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_LaJiQingYunFei", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_DiJiBuChaFei", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_ZhengCeXingBuZhu", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_GuoDuQiFangZu", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_ChaiJiuFei", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_ShiJiaoFeiYong", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_YiJiaoShuE", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_WeiJiaoShuE", SqlDbType.Decimal,9),
					new SqlParameter("@Remark", SqlDbType.VarChar,500),
					new SqlParameter("@ProtocolPhoto", SqlDbType.VarChar,80),
					new SqlParameter("@Fei_YingJiaoShuE", SqlDbType.Decimal,9),
					new SqlParameter("@An_ChaiJianNo", SqlDbType.VarChar,50),
					new SqlParameter("@An_ChaiJianArea", SqlDbType.Float,8),
					new SqlParameter("@An_GeLou", SqlDbType.Int,4),
					new SqlParameter("@Fei_FangKuanShuE", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_GeLouJinE", SqlDbType.Decimal,9),
					new SqlParameter("@Fei_ChaiJianJinE", SqlDbType.Decimal,9),
					new SqlParameter("@An_HuXing", SqlDbType.VarChar,50),
					new SqlParameter("@An_TaoShu", SqlDbType.Int,4)};
            parameters[0].Value = model.CardId;
            parameters[1].Value = model.Name;
            parameters[2].Value = model.VillageName;
            parameters[3].Value = model.Population;
            parameters[4].Value = model.Mobile;
            parameters[5].Value = model.Photo;
            parameters[6].Value = model.id;
            parameters[7].Value = model.ProtocolId;
            parameters[8].Value = model.ProtocolType;
            parameters[9].Value = model.OwnerId;
            parameters[10].Value = model.Chai_Time;
            parameters[11].Value = model.Chai_Structure;
            parameters[12].Value = model.Chai_MainCovers;
            parameters[13].Value = model.Chai_MainArea;
            parameters[14].Value = model.Chai_AttachedCovers;
            parameters[15].Value = model.Chai_AttachedArea;
            parameters[16].Value = model.Chai_Fangqianwuhou;
            parameters[17].Value = model.Chai_ReclamationLotNo;
            parameters[18].Value = model.An_Time;
            parameters[19].Value = model.An_Type;
            parameters[20].Value = model.An_Address;
            parameters[21].Value = model.An_HouseNo;
            parameters[22].Value = model.An_Covers;
            parameters[23].Value = model.An_Area;
            parameters[24].Value = model.An_BuildType;
            parameters[25].Value = model.Fei_ShiGongBaoZhengJin;
            parameters[26].Value = model.Fei_WeiYueFaKuan;
            parameters[27].Value = model.Fei_DaiJianShuiNiYingHua;
            parameters[28].Value = model.Fei_ChaiJiaJiangLi;
            parameters[29].Value = model.Fei_AnZhiYanQiBuChang;
            parameters[30].Value = model.Fei_ShiGongShuiDianFei;
            parameters[31].Value = model.Fei_ShuiBiaoKaiHuFei;
            parameters[32].Value = model.Fei_DianBiaoAnZhuangFei;
            parameters[33].Value = model.Fei_LaJiQingYunFei;
            parameters[34].Value = model.Fei_DiJiBuChaFei;
            parameters[35].Value = model.Fei_ZhengCeXingBuZhu;
            parameters[36].Value = model.Fei_GuoDuQiFangZu;
            parameters[37].Value = model.Fei_ChaiJiuFei;
            parameters[38].Value = model.Fei_ShiJiaoFeiYong;
            parameters[39].Value = model.Fei_YiJiaoShuE;
            parameters[40].Value = model.Fei_WeiJiaoShuE;
            parameters[41].Value = model.Remark;
            parameters[42].Value = model.ProtocolPhoto;
            parameters[43].Value = model.Fei_YingJiaoShuE;
            parameters[44].Value = model.An_ChaiJianNo;
            parameters[45].Value = model.An_ChaiJianArea;
            parameters[46].Value = model.An_GeLou;
            parameters[47].Value = model.Fei_FangKuanShuE;
            parameters[48].Value = model.Fei_GeLouJinE;
            parameters[49].Value = model.Fei_ChaiJianJinE;
            parameters[50].Value = model.An_HuXing;
            parameters[51].Value = model.An_TaoShu;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int id)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from View_UserWithProtocol ");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters = {
					new SqlParameter("@id", SqlDbType.Int,4)			};
            parameters[0].Value = id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 批量删除数据
        /// </summary>
        public bool DeleteList(string idlist)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from View_UserWithProtocol ");
            strSql.Append(" where id in (" + idlist + ")  ");
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DY.Model.View_UserWithProtocol GetModel(int id)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 CardId,Name,VillageName,Population,Mobile,Photo,id,ProtocolId,ProtocolType,OwnerId,Chai_Time,Chai_Structure,Chai_MainCovers,Chai_MainArea,Chai_AttachedCovers,Chai_AttachedArea,Chai_Fangqianwuhou,Chai_ReclamationLotNo,An_Time,An_Type,An_Address,An_HouseNo,An_Covers,An_Area,An_BuildType,Fei_ShiGongBaoZhengJin,Fei_WeiYueFaKuan,Fei_DaiJianShuiNiYingHua,Fei_ChaiJiaJiangLi,Fei_AnZhiYanQiBuChang,Fei_ShiGongShuiDianFei,Fei_ShuiBiaoKaiHuFei,Fei_DianBiaoAnZhuangFei,Fei_LaJiQingYunFei,Fei_DiJiBuChaFei,Fei_ZhengCeXingBuZhu,Fei_GuoDuQiFangZu,Fei_ChaiJiuFei,Fei_ShiJiaoFeiYong,Fei_YiJiaoShuE,Fei_WeiJiaoShuE,Remark,ProtocolPhoto,Fei_YingJiaoShuE,An_ChaiJianNo,An_ChaiJianArea,An_GeLou,Fei_FangKuanShuE,Fei_GeLouJinE,Fei_ChaiJianJinE,An_HuXing,An_TaoShu from View_UserWithProtocol ");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters = {
					new SqlParameter("@id", SqlDbType.Int,4)			};
            parameters[0].Value = id;

            DY.Model.View_UserWithProtocol model = new DY.Model.View_UserWithProtocol();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["CardId"] != null && ds.Tables[0].Rows[0]["CardId"].ToString() != "")
                {
                    model.CardId = ds.Tables[0].Rows[0]["CardId"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Name"] != null && ds.Tables[0].Rows[0]["Name"].ToString() != "")
                {
                    model.Name = ds.Tables[0].Rows[0]["Name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["VillageName"] != null && ds.Tables[0].Rows[0]["VillageName"].ToString() != "")
                {
                    model.VillageName = ds.Tables[0].Rows[0]["VillageName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Population"] != null && ds.Tables[0].Rows[0]["Population"].ToString() != "")
                {
                    model.Population = int.Parse(ds.Tables[0].Rows[0]["Population"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Mobile"] != null && ds.Tables[0].Rows[0]["Mobile"].ToString() != "")
                {
                    model.Mobile = ds.Tables[0].Rows[0]["Mobile"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Photo"] != null && ds.Tables[0].Rows[0]["Photo"].ToString() != "")
                {
                    model.Photo = ds.Tables[0].Rows[0]["Photo"].ToString();
                }
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ProtocolId"] != null && ds.Tables[0].Rows[0]["ProtocolId"].ToString() != "")
                {
                    model.ProtocolId = ds.Tables[0].Rows[0]["ProtocolId"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProtocolType"] != null && ds.Tables[0].Rows[0]["ProtocolType"].ToString() != "")
                {
                    model.ProtocolType = ds.Tables[0].Rows[0]["ProtocolType"].ToString();
                }
                if (ds.Tables[0].Rows[0]["OwnerId"] != null && ds.Tables[0].Rows[0]["OwnerId"].ToString() != "")
                {
                    model.OwnerId = int.Parse(ds.Tables[0].Rows[0]["OwnerId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Chai_Time"] != null && ds.Tables[0].Rows[0]["Chai_Time"].ToString() != "")
                {
                    model.Chai_Time = DateTime.Parse(ds.Tables[0].Rows[0]["Chai_Time"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Chai_Structure"] != null && ds.Tables[0].Rows[0]["Chai_Structure"].ToString() != "")
                {
                    model.Chai_Structure = ds.Tables[0].Rows[0]["Chai_Structure"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Chai_MainCovers"] != null && ds.Tables[0].Rows[0]["Chai_MainCovers"].ToString() != "")
                {
                    model.Chai_MainCovers = decimal.Parse(ds.Tables[0].Rows[0]["Chai_MainCovers"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Chai_MainArea"] != null && ds.Tables[0].Rows[0]["Chai_MainArea"].ToString() != "")
                {
                    model.Chai_MainArea = decimal.Parse(ds.Tables[0].Rows[0]["Chai_MainArea"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Chai_AttachedCovers"] != null && ds.Tables[0].Rows[0]["Chai_AttachedCovers"].ToString() != "")
                {
                    model.Chai_AttachedCovers = decimal.Parse(ds.Tables[0].Rows[0]["Chai_AttachedCovers"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Chai_AttachedArea"] != null && ds.Tables[0].Rows[0]["Chai_AttachedArea"].ToString() != "")
                {
                    model.Chai_AttachedArea = decimal.Parse(ds.Tables[0].Rows[0]["Chai_AttachedArea"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Chai_Fangqianwuhou"] != null && ds.Tables[0].Rows[0]["Chai_Fangqianwuhou"].ToString() != "")
                {
                    model.Chai_Fangqianwuhou = decimal.Parse(ds.Tables[0].Rows[0]["Chai_Fangqianwuhou"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Chai_ReclamationLotNo"] != null && ds.Tables[0].Rows[0]["Chai_ReclamationLotNo"].ToString() != "")
                {
                    model.Chai_ReclamationLotNo = ds.Tables[0].Rows[0]["Chai_ReclamationLotNo"].ToString();
                }
                if (ds.Tables[0].Rows[0]["An_Time"] != null && ds.Tables[0].Rows[0]["An_Time"].ToString() != "")
                {
                    model.An_Time = DateTime.Parse(ds.Tables[0].Rows[0]["An_Time"].ToString());
                }
                if (ds.Tables[0].Rows[0]["An_Type"] != null && ds.Tables[0].Rows[0]["An_Type"].ToString() != "")
                {
                    model.An_Type = ds.Tables[0].Rows[0]["An_Type"].ToString();
                }
                if (ds.Tables[0].Rows[0]["An_Address"] != null && ds.Tables[0].Rows[0]["An_Address"].ToString() != "")
                {
                    model.An_Address = ds.Tables[0].Rows[0]["An_Address"].ToString();
                }
                if (ds.Tables[0].Rows[0]["An_HouseNo"] != null && ds.Tables[0].Rows[0]["An_HouseNo"].ToString() != "")
                {
                    model.An_HouseNo = ds.Tables[0].Rows[0]["An_HouseNo"].ToString();
                }
                if (ds.Tables[0].Rows[0]["An_Covers"] != null && ds.Tables[0].Rows[0]["An_Covers"].ToString() != "")
                {
                    model.An_Covers = decimal.Parse(ds.Tables[0].Rows[0]["An_Covers"].ToString());
                }
                if (ds.Tables[0].Rows[0]["An_Area"] != null && ds.Tables[0].Rows[0]["An_Area"].ToString() != "")
                {
                    model.An_Area = decimal.Parse(ds.Tables[0].Rows[0]["An_Area"].ToString());
                }
                if (ds.Tables[0].Rows[0]["An_BuildType"] != null && ds.Tables[0].Rows[0]["An_BuildType"].ToString() != "")
                {
                    model.An_BuildType = ds.Tables[0].Rows[0]["An_BuildType"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Fei_ShiGongBaoZhengJin"] != null && ds.Tables[0].Rows[0]["Fei_ShiGongBaoZhengJin"].ToString() != "")
                {
                    model.Fei_ShiGongBaoZhengJin = decimal.Parse(ds.Tables[0].Rows[0]["Fei_ShiGongBaoZhengJin"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Fei_WeiYueFaKuan"] != null && ds.Tables[0].Rows[0]["Fei_WeiYueFaKuan"].ToString() != "")
                {
                    model.Fei_WeiYueFaKuan = decimal.Parse(ds.Tables[0].Rows[0]["Fei_WeiYueFaKuan"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Fei_DaiJianShuiNiYingHua"] != null && ds.Tables[0].Rows[0]["Fei_DaiJianShuiNiYingHua"].ToString() != "")
                {
                    model.Fei_DaiJianShuiNiYingHua = decimal.Parse(ds.Tables[0].Rows[0]["Fei_DaiJianShuiNiYingHua"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Fei_ChaiJiaJiangLi"] != null && ds.Tables[0].Rows[0]["Fei_ChaiJiaJiangLi"].ToString() != "")
                {
                    model.Fei_ChaiJiaJiangLi = decimal.Parse(ds.Tables[0].Rows[0]["Fei_ChaiJiaJiangLi"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Fei_AnZhiYanQiBuChang"] != null && ds.Tables[0].Rows[0]["Fei_AnZhiYanQiBuChang"].ToString() != "")
                {
                    model.Fei_AnZhiYanQiBuChang = decimal.Parse(ds.Tables[0].Rows[0]["Fei_AnZhiYanQiBuChang"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Fei_ShiGongShuiDianFei"] != null && ds.Tables[0].Rows[0]["Fei_ShiGongShuiDianFei"].ToString() != "")
                {
                    model.Fei_ShiGongShuiDianFei = decimal.Parse(ds.Tables[0].Rows[0]["Fei_ShiGongShuiDianFei"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Fei_ShuiBiaoKaiHuFei"] != null && ds.Tables[0].Rows[0]["Fei_ShuiBiaoKaiHuFei"].ToString() != "")
                {
                    model.Fei_ShuiBiaoKaiHuFei = decimal.Parse(ds.Tables[0].Rows[0]["Fei_ShuiBiaoKaiHuFei"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Fei_DianBiaoAnZhuangFei"] != null && ds.Tables[0].Rows[0]["Fei_DianBiaoAnZhuangFei"].ToString() != "")
                {
                    model.Fei_DianBiaoAnZhuangFei = decimal.Parse(ds.Tables[0].Rows[0]["Fei_DianBiaoAnZhuangFei"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Fei_LaJiQingYunFei"] != null && ds.Tables[0].Rows[0]["Fei_LaJiQingYunFei"].ToString() != "")
                {
                    model.Fei_LaJiQingYunFei = decimal.Parse(ds.Tables[0].Rows[0]["Fei_LaJiQingYunFei"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Fei_DiJiBuChaFei"] != null && ds.Tables[0].Rows[0]["Fei_DiJiBuChaFei"].ToString() != "")
                {
                    model.Fei_DiJiBuChaFei = decimal.Parse(ds.Tables[0].Rows[0]["Fei_DiJiBuChaFei"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Fei_ZhengCeXingBuZhu"] != null && ds.Tables[0].Rows[0]["Fei_ZhengCeXingBuZhu"].ToString() != "")
                {
                    model.Fei_ZhengCeXingBuZhu = decimal.Parse(ds.Tables[0].Rows[0]["Fei_ZhengCeXingBuZhu"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Fei_GuoDuQiFangZu"] != null && ds.Tables[0].Rows[0]["Fei_GuoDuQiFangZu"].ToString() != "")
                {
                    model.Fei_GuoDuQiFangZu = decimal.Parse(ds.Tables[0].Rows[0]["Fei_GuoDuQiFangZu"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Fei_ChaiJiuFei"] != null && ds.Tables[0].Rows[0]["Fei_ChaiJiuFei"].ToString() != "")
                {
                    model.Fei_ChaiJiuFei = decimal.Parse(ds.Tables[0].Rows[0]["Fei_ChaiJiuFei"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Fei_ShiJiaoFeiYong"] != null && ds.Tables[0].Rows[0]["Fei_ShiJiaoFeiYong"].ToString() != "")
                {
                    model.Fei_ShiJiaoFeiYong = decimal.Parse(ds.Tables[0].Rows[0]["Fei_ShiJiaoFeiYong"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Fei_YiJiaoShuE"] != null && ds.Tables[0].Rows[0]["Fei_YiJiaoShuE"].ToString() != "")
                {
                    model.Fei_YiJiaoShuE = decimal.Parse(ds.Tables[0].Rows[0]["Fei_YiJiaoShuE"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Fei_WeiJiaoShuE"] != null && ds.Tables[0].Rows[0]["Fei_WeiJiaoShuE"].ToString() != "")
                {
                    model.Fei_WeiJiaoShuE = decimal.Parse(ds.Tables[0].Rows[0]["Fei_WeiJiaoShuE"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Remark"] != null && ds.Tables[0].Rows[0]["Remark"].ToString() != "")
                {
                    model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProtocolPhoto"] != null && ds.Tables[0].Rows[0]["ProtocolPhoto"].ToString() != "")
                {
                    model.ProtocolPhoto = ds.Tables[0].Rows[0]["ProtocolPhoto"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Fei_YingJiaoShuE"] != null && ds.Tables[0].Rows[0]["Fei_YingJiaoShuE"].ToString() != "")
                {
                    model.Fei_YingJiaoShuE = decimal.Parse(ds.Tables[0].Rows[0]["Fei_YingJiaoShuE"].ToString());
                }
                if (ds.Tables[0].Rows[0]["An_ChaiJianNo"] != null && ds.Tables[0].Rows[0]["An_ChaiJianNo"].ToString() != "")
                {
                    model.An_ChaiJianNo = ds.Tables[0].Rows[0]["An_ChaiJianNo"].ToString();
                }
                if (ds.Tables[0].Rows[0]["An_ChaiJianArea"] != null && ds.Tables[0].Rows[0]["An_ChaiJianArea"].ToString() != "")
                {
                    model.An_ChaiJianArea = decimal.Parse(ds.Tables[0].Rows[0]["An_ChaiJianArea"].ToString());
                }
                if (ds.Tables[0].Rows[0]["An_GeLou"] != null && ds.Tables[0].Rows[0]["An_GeLou"].ToString() != "")
                {
                    model.An_GeLou = int.Parse(ds.Tables[0].Rows[0]["An_GeLou"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Fei_FangKuanShuE"] != null && ds.Tables[0].Rows[0]["Fei_FangKuanShuE"].ToString() != "")
                {
                    model.Fei_FangKuanShuE = decimal.Parse(ds.Tables[0].Rows[0]["Fei_FangKuanShuE"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Fei_GeLouJinE"] != null && ds.Tables[0].Rows[0]["Fei_GeLouJinE"].ToString() != "")
                {
                    model.Fei_GeLouJinE = decimal.Parse(ds.Tables[0].Rows[0]["Fei_GeLouJinE"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Fei_ChaiJianJinE"] != null && ds.Tables[0].Rows[0]["Fei_ChaiJianJinE"].ToString() != "")
                {
                    model.Fei_ChaiJianJinE = decimal.Parse(ds.Tables[0].Rows[0]["Fei_ChaiJianJinE"].ToString());
                }
                if (ds.Tables[0].Rows[0]["An_HuXing"] != null && ds.Tables[0].Rows[0]["An_HuXing"].ToString() != "")
                {
                    model.An_HuXing = ds.Tables[0].Rows[0]["An_HuXing"].ToString();
                }
                if (ds.Tables[0].Rows[0]["An_TaoShu"] != null && ds.Tables[0].Rows[0]["An_TaoShu"].ToString() != "")
                {
                    model.An_TaoShu = int.Parse(ds.Tables[0].Rows[0]["An_TaoShu"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select CardId,Name,VillageName,Population,Mobile,Photo,id,ProtocolId,ProtocolType,OwnerId,Chai_Time,Chai_Structure,Chai_MainCovers,Chai_MainArea,Chai_AttachedCovers,Chai_AttachedArea,Chai_Fangqianwuhou,Chai_ReclamationLotNo,An_Time,An_Type,An_Address,An_HouseNo,An_Covers,An_Area,An_BuildType,Fei_ShiGongBaoZhengJin,Fei_WeiYueFaKuan,Fei_DaiJianShuiNiYingHua,Fei_ChaiJiaJiangLi,Fei_AnZhiYanQiBuChang,Fei_ShiGongShuiDianFei,Fei_ShuiBiaoKaiHuFei,Fei_DianBiaoAnZhuangFei,Fei_LaJiQingYunFei,Fei_DiJiBuChaFei,Fei_ZhengCeXingBuZhu,Fei_GuoDuQiFangZu,Fei_ChaiJiuFei,Fei_ShiJiaoFeiYong,Fei_YiJiaoShuE,Fei_WeiJiaoShuE,Remark,ProtocolPhoto,Fei_YingJiaoShuE,An_ChaiJianNo,An_ChaiJianArea,An_GeLou,Fei_FangKuanShuE,Fei_GeLouJinE,Fei_ChaiJianJinE,An_HuXing,An_TaoShu ");
            strSql.Append(" FROM View_UserWithProtocol ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }

        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ");
            if (Top > 0)
            {
                strSql.Append(" top " + Top.ToString());
            }
            strSql.Append(" CardId,Name,VillageName,Population,Mobile,Photo,id,ProtocolId,ProtocolType,OwnerId,Chai_Time,Chai_Structure,Chai_MainCovers,Chai_MainArea,Chai_AttachedCovers,Chai_AttachedArea,Chai_Fangqianwuhou,Chai_ReclamationLotNo,An_Time,An_Type,An_Address,An_HouseNo,An_Covers,An_Area,An_BuildType,Fei_ShiGongBaoZhengJin,Fei_WeiYueFaKuan,Fei_DaiJianShuiNiYingHua,Fei_ChaiJiaJiangLi,Fei_AnZhiYanQiBuChang,Fei_ShiGongShuiDianFei,Fei_ShuiBiaoKaiHuFei,Fei_DianBiaoAnZhuangFei,Fei_LaJiQingYunFei,Fei_DiJiBuChaFei,Fei_ZhengCeXingBuZhu,Fei_GuoDuQiFangZu,Fei_ChaiJiuFei,Fei_ShiJiaoFeiYong,Fei_YiJiaoShuE,Fei_WeiJiaoShuE,Remark,ProtocolPhoto,Fei_YingJiaoShuE,An_ChaiJianNo,An_ChaiJianArea,An_GeLou,Fei_FangKuanShuE,Fei_GeLouJinE,Fei_ChaiJianJinE,An_HuXing,An_TaoShu ");
            strSql.Append(" FROM View_UserWithProtocol ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            strSql.Append(" order by " + filedOrder);
            return DbHelperSQL.Query(strSql.ToString());
        }

        /// <summary>
        /// 获取记录总数
        /// </summary>
        public int GetRecordCount(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) FROM View_UserWithProtocol ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            object obj = DbHelperSQL.GetSingle(strSql.ToString());
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT * FROM ( ");
            strSql.Append(" SELECT ROW_NUMBER() OVER (");
            if (!string.IsNullOrEmpty(orderby.Trim()))
            {
                strSql.Append("order by T." + orderby);
            }
            else
            {
                strSql.Append("order by T.id desc");
            }
            strSql.Append(")AS Row, T.*  from View_UserWithProtocol T ");
            if (!string.IsNullOrEmpty(strWhere.Trim()))
            {
                strSql.Append(" WHERE " + strWhere);
            }
            strSql.Append(" ) TT");
            strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
            return DbHelperSQL.Query(strSql.ToString());
        }

        /*
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        {
            SqlParameter[] parameters = {
                    new SqlParameter("@tblName", SqlDbType.VarChar, 255),
                    new SqlParameter("@fldName", SqlDbType.VarChar, 255),
                    new SqlParameter("@PageSize", SqlDbType.Int),
                    new SqlParameter("@PageIndex", SqlDbType.Int),
                    new SqlParameter("@IsReCount", SqlDbType.Bit),
                    new SqlParameter("@OrderType", SqlDbType.Bit),
                    new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
                    };
            parameters[0].Value = "View_UserWithProtocol";
            parameters[1].Value = "id";
            parameters[2].Value = PageSize;
            parameters[3].Value = PageIndex;
            parameters[4].Value = 0;
            parameters[5].Value = 0;
            parameters[6].Value = strWhere;	
            return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
        }*/

        #endregion  Method
    }
}

